home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9529 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  64 lines

  1. Path: news.netgate.net!news
  2. From: Tamara Johnson <malihini@netgate.net>
  3. Newsgroups: comp.lang.c
  4. Subject: ?Help - struct array of strings
  5. Date: 10 Mar 1996 23:44:25 GMT
  6. Organization: NetGate Communications
  7. Message-ID: <4hvpgp$gu7@ftp.netgate.net>
  8. NNTP-Posting-Host: d49.netgate.net
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=iso-8859-1
  11. Content-Transfer-Encoding: 8bit
  12. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  13.  
  14. /*
  15.    program to enter author(s), title(s)
  16.    then display entries.
  17.    why is printf displaying strange things?
  18.    (see output at end)
  19. */
  20.  
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <conio.h>
  24. #include <string.h>
  25.  
  26. #define MAX 5
  27.  
  28. struct catalog{
  29.   char name[80];        /* author name */
  30.   char title[80];    /* title */ 
  31. }cat[80];
  32.  
  33. void main()
  34.  
  35. {
  36. int i;
  37.  
  38. for(i=0;i<MAX;i++) 
  39.   {
  40.   printf("Enter author name (ENTER to quit); ");
  41.   gets(cat[i].name);
  42.   if(!*cat[i].name) break;
  43.   printf("Enter title: ");
  44.   gets(cat[i].title);
  45.   }
  46. for(i=0;i<MAX;i++)
  47.   printf("%c %c\n", cat[i].name, cat[i].title);
  48. }
  49. /*
  50. output;
  51.  
  52. Enter author name (ENTER to quit); tom
  53. Enter title: pickled peppers
  54. Enter author name (ENTER to quit); sam
  55. Enter title: hop on pop
  56. Enter author name (ENTER to quit);
  57. ` t
  58. Ω ú
  59. _ -
  60. + _
  61.   ╢
  62. */
  63.  
  64.